package com.kingyea.app.market.utils;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description 全局常量
 * @date Created in 201-1-1 00:15:41
 */
@Component
@ConfigurationProperties(prefix = "kingyea.mobilepolice.market")
//@PropertySource(value = {"classpath:application.properties"},encoding="UTF-8")// 依赖set方法
public class GlobalVar extends GlobalVarComm {

    public final static String TOP_LEVEL_ORGANIZATION = "-1";
    public final static int MODULE_APP = 1;//app文件存放模块
    public final static int MODULE_SHOW_IMG = 2;//app展示图片存放模块
    public final static int MODULE_LOGO_IMG = 3;//app logo图标存放模块
    public final static String MODULE_APP_URL = "/file/app/";//app文件存放模块对应路径
    public final static String MODULE_SHOW_IMG_URL = "/file/img/app_show/";//app展示图片存放模块对应路径
    public final static String MODULE_LOGO_IMG_URL = "/file/img/app_logo/";//app logo图标存放模块对应路径
    public final static int SYS_MARKET = 1;//应用市场系统序号
    public final static int SYS_API_MANAGER = 2;//api管理系统序号
    public static String FILE_DIR = "z:/nginxFile";//windows
    public static String FILE_HOST = "http://192.168.0.65:9966";
    /**
     * (由项目自动初始化)本地市场编码
     */
    public static String marketCode = "";


    /** --------------------------------------------- 以下变量dataBase专用 -------------------------------------------------- */
    /**
     * (由项目自动初始化)本地市场分类,1:一类市场，2：二类市场，3：三类市场
     */
    public static Integer marketClassify = 999;
    /**
     * (由项目自动初始化)本地市场是否具有管理权限
     */
    public static Integer adminMarket = 999;
    /**
     * --------------------------------------------- 通用变量 --------------------------------------------------
     */
    private static Boolean isDev;

    public static String getFileUrl(int module) {
        switch (module) {
            case MODULE_APP:
                return MODULE_APP_URL;
            case MODULE_SHOW_IMG:
                return MODULE_SHOW_IMG_URL;
            case MODULE_LOGO_IMG:
                return MODULE_LOGO_IMG_URL;
        }
        return "";
    }

    public static boolean supportSys(int sys) {
        switch (sys) {
            case SYS_MARKET:
                return true;
            case SYS_API_MANAGER:
                return true;
        }
        return false;
    }

    public static boolean supportModule(int module) {
        switch (module) {
            case MODULE_APP:
                return true;
            case MODULE_SHOW_IMG:
                return true;
            case MODULE_LOGO_IMG:
                return true;
        }
        return false;
    }

    public static int getModuleApp() {
        return MODULE_APP;
    }

    public static int getModuleShowImg() {
        return MODULE_SHOW_IMG;
    }

    public static int getModuleLogoImg() {
        return MODULE_LOGO_IMG;
    }

    public static String getModuleAppUrl() {
        return MODULE_APP_URL;
    }

    public static String getModuleShowImgUrl() {
        return MODULE_SHOW_IMG_URL;
    }

    public static String getModuleLogoImgUrl() {
        return MODULE_LOGO_IMG_URL;
    }

    public static String getFileDir() {
        return FILE_DIR;
    }

    @Value("${kingyea.mobilepolice.FILE_DIR}")
    public void setFileDir(String fileDir) {
        FILE_DIR = fileDir;
    }

    public static String getFileHost() {
        return FILE_HOST;
    }

    @Value("${kingyea.mobilepolice.FILE_HOST}")
    public void setFileHost(String fileHost) {
        FILE_HOST = fileHost;
    }

    public static int getSysMarket() {
        return SYS_MARKET;
    }

    public static int getSysApiManager() {
        return SYS_API_MANAGER;
    }

    public static Boolean getIsDev() {
        return isDev;
    }

    @Value("${kingyea.mobilepolice.market.isDev}")
    public void setIsDev(Boolean isDev) {
        GlobalVar.isDev = isDev;
    }

    public static String getMarketCode() {
        return marketCode;
    }

    public void setMarketCode(String marketCode) {
        GlobalVar.marketCode = marketCode;
    }

    public static Integer getMarketClassify() {
        return marketClassify;
    }

    public void setMarketClassify(Integer marketClassify) {
        GlobalVar.marketClassify = marketClassify;
    }

    public static Integer getAdminMarket() {
        return adminMarket;
    }

    public void setAdminMarket(Integer adminMarket) {
        GlobalVar.adminMarket = adminMarket;
    }


}
